/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nattakute.model;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.codehaus.jackson.annotate.JsonBackReference;

/**
 *
 * @author simple7211
 */
@Entity
@Table(name = "request")

public class Request implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "requestID")
    private Integer requestId;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "title")
    private String title;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "description")
    private String description;
    
    @JsonBackReference
    @JoinColumn(name = "userID", referencedColumnName = "userID")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Users user;
    
    
    @JsonBackReference
    @JoinColumn(name = "timeTableID", referencedColumnName = "timeTableID")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Timetable timeTable;
    

    @Basic(optional = false)
    @Column(name = "statusID")
    private Boolean statusId;
    
    @JsonBackReference
    @JoinColumn(name = "instructor", referencedColumnName = "userID")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Users instructor;
    
    public Request() {
    }

    public Request(Integer requestId) {
        this.requestId = requestId;
    }

    public Request(Integer requestId, String title, String description) {
        this.requestId = requestId;
        this.title = title;
        this.description = description;
    }

    
    

    public Integer getRequestId() {
		return requestId;
	}

	public void setRequestId(Integer requestId) {
		this.requestId = requestId;
	}

	public Boolean getStatusId() {
		return statusId;
	}

	public void setStatusId(Boolean statusId) {
		this.statusId = statusId;
	}

	public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

	public Users getUser() {
		return user;
	}

	public void setUser(Users user) {
		this.user = user;
	}

	public Timetable getTimeTable() {
		return timeTable;
	}

	public void setTimeTable(Timetable timeTable) {
		this.timeTable = timeTable;
	}

	
	
	public Users getInstructor() {
		return instructor;
	}

	public void setInstructor(Users instructor) {
		this.instructor = instructor;
	}

	@Override
    public int hashCode() {
        int hash = 0;
        hash += (requestId != null ? requestId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Request)) {
            return false;
        }
        Request other = (Request) object;
        if ((this.requestId == null && other.requestId != null) || (this.requestId != null && !this.requestId.equals(other.requestId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.da.model.Request[ requestID=" + requestId + " ]";
    }
    
}
